﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MVC4CodeSamples.Areas.JQueryGrid.Models
{  
    public class Customer
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
        public string EmployeeCode { get; set; }
    }

    // This static class serves as a repository of the customer collection
    public static class CustomerRepository
    {
        private static readonly List<Customer> customers = new List<Customer>();
        public static List<Customer> GetCustomers() { return customers; }

        // Static constructor to initiate some customers in the repository
        static CustomerRepository()
        {
            int total = 105;

            DateTime now = DateTime.Now;
            var scoreRand = new Random();
            var enrollmentRand = new Random();
            for (int i = 1; i <= total; i++)
            {
                var customer = new Customer();
                customer.Id = i;
                customer.Name = "Name" + i.ToString();
                customer.Age = 60
               + Convert.ToInt16(scoreRand.NextDouble() * 40);
                if (customer.Age > 80)
                    customer.Age = customer.Age - 30;
                DateTime tmpDate = now.AddDays(-1 * (int)(enrollmentRand.NextDouble() * 365 * 10));
                customer.EmployeeCode = tmpDate.ToString("yyyyMMdd");                 
                customers.Add(customer);
            }
        }
    }
}